//获取全部照片
export const getAllPhotoWall = async(req,res)=>{
    try{
        const photo = await req.db.photoWall.findMany({})
        res.send({success: true, data: photo})
    }catch(e){
        res.fail({success: false, message: '获取照片失败'})
    }
}

//添加照片
export const addPhotoWall = async(req,res)=>{
    const { photoPath } = req.body
    if(!photoPath) return res.fail('照片地址不能为空')
    try{
        const path = { photoPath }
        await req.db.photoWall.create({
            data: path
        })
        res.send({success:true , message: '照片上传成功'})
    }catch(e){
        res.fail({success:false , message: '照片上传失败'})
        console.log(e)
    }
}
//删除照片
export const delPhotoWall = async(req,res)=>{
    const { id } = req.body
    if(!id) return res.fail('照片id不能为空')
    try{
        await req.db.photoWall.delete({
            where: {
                id:Number(id)
            }
        })
        res.send({success:true , message: '照片删除成功'})
    }catch(e){
        console.log(e)
        res.fail({success:false , message: '照片删除失败'})
    }
}